import ajax from '@/utils/request';
// 按模块配置接口 
export const common = {
	login_wx(data) {
		return ajax.post('/app-account/login', {
			code: data.code,
			parentId: data.parentId || ''
		})
	},
	login_ks(data) {
		return ajax.post('/app-account/ks-login', {
			code: data.code,
			parentId: data.parentId || ''
		})
	},
	express() {
		return ajax.get('/common/express')
	},
	store() {
		return ajax.get('/store/list')
	},
    complete(params) {
		return ajax.post('/app-account/complete', params)
	}
};

export const config = {
	service() {
		return ajax.get('/common/service')
	},
	rechageStore() {
		return ajax.get('/common/rechage-store')
	},
	dict(params) {
		return ajax.get('/common/dict', params)
	},
	expressFee() {
		return ajax.get('/common/express-fee')
	},
	expressPeriodFee() {
		return ajax.get('/common/express-period-fee')
	}
}

export const charge = {
	pay(params) {
		return ajax.post('/recharge/pay', params)
	},
	history(params) {
		return ajax.post('/recharge/history', params)
	}
}

export const goods = {
	categorys() {
		return ajax.get('/category/get')
	},
	getByCategory(params) {
		return ajax.post('/goods/getByCategory', params)
	},
	search(params) {
		return ajax.post('/goods/search', params)
	},
	detail(params) {
		return ajax.get('/goods/detail', params)
	},
	history(params) {
		return ajax.post('/goods/history', params)
	},
	recommended(params) {
		return ajax.post('/goods/recommended', params)
	},
}

export const cart = {
  add(params) {
		return ajax.post('/shopping-trolley/add', params)
	},
  count() {
		return ajax.get('/shopping-trolley/count')
	},
  get() {
		return ajax.get('/shopping-trolley/get')
	},
  delete(params) {
		return ajax.delete('/shopping-trolley/delete', {}, { params: params })
	},
  update(params) {
		return ajax.put('/shopping-trolley/update', params)
	},
}

export const user = {
	address() {
		return ajax.get('/address/list')
	},
	addressAdd(params) {
		return ajax.post('/address/add', params)
	},
	addressUpdate(params) {
		return ajax.put('/address/update', params)
	},
	addressDelete(params) {
		return ajax.delete('/address/delete', {}, { params: params })
	},
	addressSetDefualt(params) {
		return ajax.put('/address/set-defualt', params)
	},
	wxQrCode(params) {
		return ajax.post('/app-account/qrCode', params)
	},
	ksQrCode(params) {
		return ajax.post('/app-account/ks-qrCode', params)
	},
}

export const order = {
  add(params) {
    return ajax.post('/trade/add', params)
  },
  detail(params) {
    return ajax.get('/trade/detail', params)
  },
  cancel(params) {
    return ajax.get('/trade/cancel', params)
  },
  wallet() {
    return ajax.get('/wallet/get')
  },
  trace(params) {
    return ajax.post('/wallet/trace', params)
  },
  checkstand(params) {
    return ajax.get('/trade/checkstand', params)
  },
  pay(params) {
    return ajax.post('/trade/pay', params)
  },
  confirm(params) {
    return ajax.get('/trade/confirm', params)
  },
  page(params) {
    return ajax.post('/trade/page', params)
  },
  counter() {
    return ajax.get('/trade/counter')
  },
  appeal(params) {
    return ajax.post('/trade/appeal', params)
  },
  appealDetail(params) {
    return ajax.get('/trade/appeal-detail', params)
  },
}

export const wallet = {
  pay(params) {
    return ajax.post('/recharge/pay', params)
  },
  rechargeStore() {
    return ajax.get('/common/recharge-store')
  },
  history(params) {
    return ajax.post('/recharge/history', params)
  },
}
export const activity = {
  seckills(params) {
    return ajax.post('/seckill/activities', params)
  },
  seckillGoods(params) {
    return ajax.post('/seckill/goods', params)
  },
  seckillTrade(params) {
    return ajax.post('/seckill/add-trade', params)
  },
}

